home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- set -e
-
- # summary of how this script can be called:
- # * <postinst> `configure' <most-recently-configured-version>
- # * <old-postinst> `abort-upgrade' <new version>
- # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
- # <new-version>
- # * <postinst> `abort-remove'
- # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
- # <failed-install-package> <version> `removing'
- # <conflicting-package> <version>
- # for details, see http://www.debian.org/doc/debian-policy/ or
- # the debian-policy package
-
- rotate_old_log_files()
- {
- log_files="syslog mail.info mail.warn mail.err mail.log daemon.log \
- kern.log auth.log user.log lpr.log cron.log debug messages"
- skipped_files=""
- dir=/var/log
-
- for f in $log_files; do
- if [ -e $dir/$f.0 ]; then
- rotate="yes"
- if [ -e $dir/$f.1.gz ]; then
- date0=$(stat --format=%Y $dir/$f.0)
- date1=$(stat --format=%Y $dir/$f.1.gz)
- if [ $date0 -lt $date1 ] ; then
- # .0 log file is older than .1
- skipped_files="$dir/$f.0\n$skipped_files"
- rotate="no"
- fi
- fi
- if [ "$rotate" = "yes" ] ; then
- for s in $(seq 9 -1 1) ; do
- if [ -e $dir/$f.$s.gz ]; then
- mv $dir/$f.$s.gz $dir/$f.$(($s+1)).gz
- fi
- done
- mv $dir/$f.0 $dir/$f.1
- fi
- fi
- done
- if [ -n "$skipped_files" ]; then
- printf "The following old log files were found which could not be rotated safely.\n"
- printf "\n$skipped_files\n"
- printf "Please inspect them manually and delete them, if no longer required.\n"
- fi
- }
-
-
- case "$1" in
- configure)
- # Rotate .0 log files when migrating from sysklogd
- if dpkg --compare-versions "$2" lt "3.18.5-1"; then
- rotate_old_log_files
- fi
-
- user_conf=/etc/rsyslog.d/50-default.conf
- default_conf=/usr/share/rsyslog/50-default.conf
-
- # Upgrade handling for config file. We copy syslog.conf if it exists and
- # is modified, else use our default fresh-install config.
- if dpkg --compare-versions "$2" lt "3.22.0-1ubuntu1"; then
- pkg_name=sysklogd
- old_conf=/etc/syslog.conf
- if [ -e $old_conf ]; then
- md5sum="`md5sum \"$old_conf\" | sed -e \"s/ .*//\"`"
- old_md5sum="$(dpkg-query -W -f='${Conffiles}' $pkg_name | \
- sed -n -e "\' $old_conf ' { s/ obsolete$//; s/.* //; p }")"
- if [ "$md5sum" != "$old_md5sum" ]; then
- cp -n $old_conf $user_conf
- fi
- fi
- fi
-
- ucf --three-way --debconf-ok $default_conf $user_conf
- ucfr rsyslog $user_conf
-
- adduser --system --group --no-create-home --quiet syslog || true
-
- # Gross hack to stop an error when upgrading from sysklogd to rsyslog.
- # sysklogd tries to 'deluser syslog' but rsyslog will be running by then.
- # It was decided sysklogd should not be trying to delete the user at all.
- # So we correct that mistake by sed'ing sysklogd's postrm script.
- # See LP: #401056
- if [ -e /var/lib/dpkg/info/sysklogd.postrm ]; then
- sed -i -e '/deluser/d' /var/lib/dpkg/info/sysklogd.postrm
- fi
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
- ;;
-
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
- esac
-
-
- # Automatically added by dh_installinit
- if [ -x "/etc/init.d/rsyslog" ]; then
- if [ -n "$2" ]; then
- _dh_action=restart
- else
- _dh_action=start
- fi
- invoke-rc.d rsyslog $_dh_action || exit $?
- fi
- # End automatically added section
- # Automatically added by dh_installinit
- update-rc.d -f rsyslog remove >/dev/null || exit $?
- # End automatically added section
-
-
- exit 0
-